home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc1_2_x / fretext1.sit / Free Text Browser v1.01 / stack.txt < prev   
Text File  |  1990-04-13  |  11KB  |  323 lines

  1. -- stack: in.01
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 3
  11. -- first background id: 2734
  12. -- card count: 4
  13. -- first card id: 2966
  14. -- list block id: 4588
  15. -- print block id: 2124
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 50080 bytes
  21. -- stack block size: 10240 bytes
  22. -- created by hypercard version: 0x01208000
  23. -- compacted by hypercard version: 0x01228000
  24. -- modified by hypercard version: 0x01228000
  25. -- opened by hypercard version: 0x01228000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. on openStack
  69.   -- do some checking to be sure all is well...
  70.   if the version < 1.2 then
  71.     beep
  72.     answer "Sorry, need newer version of HyperCard!"
  73.   end if
  74.   if the number of this card is 1 then
  75.     if field "Text" is empty then
  76.       put "Free Text Browser - Copyright ┬⌐ 1990 - Mark Zimmermann" & return & "Click on the '?' for help." & return & "This program is free and comes with NO WARRANTY whatsoever!" into field "Text"
  77.     end if
  78.   end if
  79.   initGlobals    -- set up many things for this stack
  80.   if item 4 of the screenrect <= 342 then hide menuBar
  81.   pass openStack
  82. end openStack
  83.  
  84. on closeStack
  85.   -- close out files, vars, empty fields nicely
  86.   set cursor to watch
  87.   lock screen
  88.   repeat for the number of cards -- close all database files
  89.     if the short name of this bkgnd is "BrowserBg" then closeDatabase
  90.     go to next card
  91.   end repeat
  92.   show menuBar
  93.   pass closeStack
  94. end closeStack
  95.  
  96. on closeDatabase
  97.   -- called before opening a file as well as when leaving the stack
  98.   get openCloseFiles (getTextFileRefNum(), getKeyFileRefNum(), getPtrFileRefNum())
  99.   if not (getSubsetHandle(1) = 0 or getSubsetHandle(1) = empty) then
  100.     get zbrowser ("RELEASESUBSET", getSubsetHandle(1))
  101.     setSubsetHandle 1,0
  102.   end if
  103.   if not (getSubsetHandle(2) = 0 or getSubsetHandle(2) = empty) then
  104.     get zbrowser ("RELEASESUBSET", getSubsetHandle(2))
  105.     setSubsetHandle 2,0
  106.   end if
  107.   put empty into field "FTVars"
  108.   put empty into field "Index1"
  109.   put empty into field "Index2"
  110.   put empty into field "Context"
  111.   put empty into field "Text"
  112.   put empty into field "Database Name"
  113.   if the height of field "Text" > 169 then
  114.     send mouseUp to bg button id 44
  115.   end if
  116.   hide field "searchPattern1"
  117.   hide field "searchPattern2"
  118.   hide bg button "and subsets"
  119.   hide bg button "or subsets"
  120.   hide bg button "not subset 1"
  121.   hide bg button "not subset 2"
  122.   hide bg button "fill subset 1"
  123.   hide bg button "fill subset 2"
  124. end closeDatabase
  125.  
  126. on initGlobals
  127.   -- initialize many things here for the stack to use globally
  128.   global indexLines, contextLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth, contextLineLength, contextWordOffset, maxContextLinesSkipped, textChunkSize, textOffset, errorCount, contextGutterWidth, whichSubset
  129.   put 7 into indexLines -- hold this many lines in Index fields
  130.   put 7 into contextLines -- hold this many lines in Context field
  131.   put 100 into maxIndexSampleCount -- sample size during subset counts
  132.   put 5 into indexCountWidth -- this many digits of count info for Index
  133.   put 28 into indexKeyWidth -- this many letters of Index words
  134.   put 80 into contextLineLength -- this many letters of Context
  135.   put 35 into contextWordOffset -- key word starts in this column
  136.   put 100 into maxContextLinesSkipped
  137.   -- make a line of dots after this many lines in subset are skipped
  138.   put 8192 into textChunkSize -- grab this much for text field
  139.   put 4096 into textOffset -- put key word this far into text chunk
  140.   put 0 into errorCount -- initialize counter to control error display
  141.   put 0 into contextGutterWidth -- spaces before key word
  142.   put 1 into whichSubset -- identify which subset, 1 or 2, is being used
  143. end initGlobals
  144.  
  145. on checkOpenDatabase
  146.   -- test to catch attempt to operate without an open indexed file;
  147.   -- try turning it into an "Open Database" request if so!
  148.   if (getTextFileRefNum() = 0  or getTextFileRefNum() = empty) then
  149.     beep
  150.     answer "No database open!"
  151.     exit to HyperCard
  152.   end if
  153. end checkOpenDatabase
  154.  
  155. function clickedLineNum
  156. -- compute which line number of the field got the click
  157. return 1 + trunc((item 2 of the clickLoc - (item 2 of (the rectangle of the target))) / (the textheight of the target))
  158. end clickedLineNum
  159.  
  160. function clickedOnLeftHalf
  161. -- see if click was on left half of the button, for AND and OR subsets
  162. put item 1 of the clickLoc into clickX
  163. put ((item 1 of the rect of the target) + (item 3 of the rect of the target)) / 2 into midPointX
  164. return (clickX < midPointX)
  165. end clickedOnLeftHalf
  166.  
  167. on browseIndex1
  168.   -- fill Index field #1
  169.   global indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth
  170.   get zbrowser ("INDEX", getwordnum1(), indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth, getKeyFileRefNum(), getPtrFileRefNum(), getSubsetHandle(1))
  171.   put line 1 to indexLines of It into field "Index1"
  172.   setInstanceList1 (line (indexLines+1) to (2*indexLines) of It)
  173. end browseIndex1
  174.  
  175. on browseIndex2
  176.   -- fill Index field #2
  177.   global indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth
  178.   get zbrowser ("INDEX", getwordnum2(), indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidth, getKeyFileRefNum(), getPtrFileRefNum(), getSubsetHandle(2))
  179.   put line 1 to indexLines of It into field "Index2"
  180.   setInstanceList2 (line (indexLines+1) to (2*indexLines) of It)
  181. end browseIndex2
  182.  
  183. on browseContext lineOffset
  184.   -- fill the Context field
  185.   global contextLines, contextLineLength, contextWordOffset, maxContextLinesSkipped, contextGutterWidth, whichSubset
  186.   get zbrowser ("CONTEXT", getInstanceNum(), contextLines, lineOffset, contextLineLength, contextWordOffset, maxContextLinesSkipped, contextGutterWidth, getPtrFileRefNum(), getTextFileRefNum(), getSubsetHandle(whichSubset))
  187.   put line 1 to contextLines of It into field Context
  188.   setTextPtrList (line (contextLines+1) to (2*contextLines) of It)
  189. end browseContext
  190.  
  191. --
  192. -- the remaining functions set and fetch values of various useful
  193. -- quantities; do it this way to hide the details of how things are
  194. -- stored....
  195. --
  196.  
  197. function getTextFileRefNum
  198. return line 1 of field FTVars
  199. end getTextFileRefNum
  200.  
  201. on setTextFileRefNum refNum
  202.   put refNum into line 1 of field FTVars
  203. end setTextFileRefNum
  204.  
  205. function getKeyFileRefNum
  206. return line 2 of field FTVars
  207. end getKeyFileRefNum
  208.  
  209. on setKeyFileRefNum refNum
  210.   put refNum into line 2 of field FTVars
  211. end setKeyFileRefNum
  212.  
  213. function getPtrFileRefNum
  214. return line 3 of field FTVars
  215. end getPtrFileRefNum
  216.  
  217. on setPtrFileRefNum refNum
  218.   put refNum into line 3 of field FTVars
  219. end setPtrFileRefNum
  220.  
  221. function getWordNum1
  222. return line 4 of field FTVars
  223. end getWordNum1
  224.  
  225. on setWordNum1 wordNum
  226.   put wordNum into line 4 of field FTVars
  227. end setWordNum1
  228.  
  229. function getWordNum2
  230. return line 5 of field FTVars
  231. end getWordNum2
  232.  
  233. on setWordNum2 wordNum
  234.   put wordNum into line 5 of field FTVars
  235. end setWordNum2
  236.  
  237. function getInstanceNum
  238. return line 6 of field FTVars
  239. end getInstanceNum
  240.  
  241. on setInstanceNum instanceNum
  242.   put instanceNum into line 6 of field FTVars
  243. end setInstanceNum
  244.  
  245. function getTextStart
  246. return line 7 of field FTVars
  247. end getTextStart
  248.  
  249. on setTextStart textStart
  250.   put textStart into line 7 of field FTVars
  251. end setTextStart
  252.  
  253. function getTextTarget
  254. return line 8 of field FTVars
  255. end getTextTarget
  256.  
  257. on setTextTarget textTarget
  258.   put textTarget into line 8 of field FTVars
  259. end setTextTarget
  260.  
  261. function getTextEnd
  262. return line 9 of field FTVars
  263. end getTextEnd
  264.  
  265. on setTextEnd textEnd
  266.   put textEnd into line 9 of field FTVars
  267. end setTextEnd
  268.  
  269. function getSubsetHandle subsetNumber
  270. return line 9+subsetNumber of field FTVars
  271. end getSubsetHandle
  272.  
  273. on setSubsetHandle subsetNumber, handle
  274.   put handle into line 9+subsetNumber of field FTVars
  275. end setSubsetHandle
  276.  
  277. function getNeighborhoodSize
  278. return line 12 of field FTVars
  279. end getNeighborhoodSize
  280.  
  281. on setNeighborhoodSize size
  282.   put size into line 12 of field FTVars
  283. end setNeighborhoodSize
  284.  
  285. -- lines 13 through 19 of field FTVars are currently unused
  286.  
  287. function getInstanceList1item instanceNum
  288. return line 19+instanceNum of field FTVars
  289. end getInstanceList1item
  290.  
  291. on setInstanceList1 instanceList
  292.   global indexLines
  293.   put instanceList into line 20 to 19+indexLines of field FTVars
  294. end setInstanceList1
  295.  
  296. function getInstanceList2item instanceNum
  297. global indexLines
  298. return line 19+indexLines+instanceNum of field FTVars
  299. end getInstanceList2item
  300.  
  301. on setInstanceList2 instanceList
  302.   global indexLines
  303.   put instanceList into line 20+indexLInes to 19+2*indexLines of field FTVars
  304. end setInstanceList2
  305.  
  306. function getTextPtrListInstanceItem itemNum
  307. global indexLines, contextLines
  308. return word 1 of line 19+2*indexLines+itemNum of field FTVars
  309. end getTextPtrListInstanceItem
  310.  
  311. function getTextPtrListPtrItem itemNum
  312. global indexLines, contextLines
  313. return word 2 of line 19+2*indexLines+itemNum of field FTVars
  314. end getTextPtrListPtrItem
  315.  
  316. on setTextPtrList textPtrList
  317.   global indexLines, contextLines
  318.   put textPtrList into line 20+2*indexLInes to 19+2*indexLines +contextLines of field FTVars
  319. end setTextPtrList
  320.  
  321.  
  322.  
  323.